@ECHO OFF

REM RESTful DDS is a prototyping effort to demonstrate how DDS could be combined
REM with HTTP clients, extending the realm of pub/sub distribution to true wide
REM area networking.
REM
REM Copyright (C) 2009 PrismTech Ltd.
REM reinier.torenbeek@gmail.com
REM
REM This library is free software; you can redistribute it and/or
REM modify it under the terms of the GNU Lesser General Public
REM License Version 3 dated 29 June 2007, as published by the
REM Free Software Foundation.
REM
REM This library is distributed in the hope that it will be useful,
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
REM Lesser General Public License for more details.
REM
REM You should have received a copy of the GNU Lesser General Public
REM License along with DDSTouchStone; if not, write to the Free Software
REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

SET GEN_DIR=generated
SET OBJ_DIR=obj
SET LIB_DIR=lib

SET SERVICE_PKG=org.opensplice.restful.service
SET SERVICE_DIR=org\opensplice\restful\service
SET SERVICE_SOURCE_DIR=src\%SERVICE_DIR%
SET SERVICE_JAR=%LIB_DIR%\%SERVICE_PKG%.jar

SET CHAT_DIR=Chat
SET CHAT_SOURCE_DIR=%GEN_DIR%\%CHAT_DIR%

REM Call batch file containing locations of external jar files.
REM Edit externals.bat if you want to point to the jars other than the
REM default locations.
CALL externals.bat
SET EXTERNAL_JARS=%RESTLET_INTF_JAR%;%RESTLET_IMPL_JAR%;%GSON_JAR%

REM First generate code for built in test
REM This is not required for the service to work, but is left in here for
REM testing purposes.
ECHO Generating test classes using OpenSplice
IF NOT EXIST %GEN_DIR% MD %GEN_DIR%
idlpp -S -l java -d %GEN_DIR% "%CHAT_IDL%"

REM Compile generated source code
ECHO Compiling generated Tutorial source code
IF NOT EXIST %OBJ_DIR% MD %OBJ_DIR%
javac -sourcepath %GEN_DIR% -d %OBJ_DIR% -classpath "%OBJ_DIR%;%DDS_JAR%" %CHAT_SOURCE_DIR%\*.java

REM Compile service source code
IF NOT EXIST %OBJ_DIR% MD %OBJ_DIR%
ECHO Compiling RESTfulDDS service source code
javac -sourcepath %SERVICE_SOURCE_DIR% -d %OBJ_DIR% -classpath "%OBJ_DIR%;%DDS_JAR%;%EXTERNAL_JARS%" %SERVICE_SOURCE_DIR%\*.java

IF NOT EXIST %LIB_DIR% MD %LIB_DIR%
ECHO Creating RESTfulDDS service jar file
jar cf %SERVICE_JAR% -C %OBJ_DIR% %SERVICE_DIR%

IF EXIST Tutorial (
    ECHO Skipped building of chatroom tutorial because it seems to be there already
) else (
    ECHO Copying and building OpenSplice chatroom tutorial
    XCOPY /S /I "%OSPL_HOME%\examples\dcps\standalone\Java\Tutorial" Tutorial
    PUSHD Tutorial
    call BUILD.bat
    POPD
)
